package avicit.bdp.dds.common.utils;

import avicit.bdp.common.dto.StorageResourceConf;
import avicit.bdp.common.service.service.FileOperateCommonService;
import avicit.bdp.common.utils.SpringApplicationContext;
import avicit.bdp.common.utils.file.StorageConfThreadLocal;
import avicit.platform6.core.exception.BusinessException;

/**
 * TODO
 *
 * @author xugb
 * @date 2022/4/19 10:26
 */
public class StorageResourceConfUtils {
    public static StorageResourceConf getCurrentStorageResourceConf(){
        StorageResourceConf storageResourceConf = StorageConfThreadLocal.getThreadLocal();
        if (storageResourceConf == null) {
            storageResourceConf = SpringApplicationContext.getBean(FileOperateCommonService.class).getDefaultStorage();
            if (storageResourceConf == null) {
                throw new BusinessException("获取缓存配置信息为空");
            }
            StorageConfThreadLocal.setThreadLocal(storageResourceConf);
        }
        return storageResourceConf;
    }
}
